/*
 * AS_RESOURCE_RELOAD.cpp
 *
 *  Created on: 2013. 12. 5.
 *      Author: mega
 */

#include "../../User.h"
#include "../../Proxy.h"
#include "../../Command.h"
#include "../../NResource/Static.h"
#include "../../../../protocol/Guild.h"

namespace ProjectZ { namespace NCommand {

void Command::AS_RESOURCE_RELOAD(User * pUser, ::Network::Packet * pPacket)
{
	PREPARE_PACKET;

	bool bLoadResource = NResource::Static::InstancePtr()->LoadResource(NResource::Static::E_TYPE::_ALL_);
	DEBUGLOG("RELOAD RESOURCE RESULT=%d", bLoadResource);

	bool bLoadConfig = Config::Instance().LoadDatabase();
	DEBUGLOG("RELOAD CONFIG RESULT=%d", bLoadConfig);

	::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
	*pAck << static_cast<uint8_t>(bLoadResource);
	*pAck << static_cast<uint8_t>(bLoadConfig);
	pAck->MakePacket(CMD_SA_RESOURCE_RELOAD);
	pUser->Send(pAck);

	// 길드 서버 ResourceReload
	ReloadResourceSyn syn;
	auto iter = NProxy::GetGuildServerTree().begin();
	for (; iter != NProxy::GetGuildServerTree().end(); ++iter)
	{
		if (false == iter->second->IsConnect())
			continue;

		iter->second->SendMessage(syn);
	}
}

} /*NCommand*/ } /*ProjectZ*/
